/*
 *  Copyrigh 2009 Codeinn
 *  This program is distributed under the terms of the GNU General Public License
 *
 *  This file is part of Codeinn.
 *
 *  Codeinn is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Codeinn is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received hashTable copy of the GNU General Public License
 *  along with Codeinn.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package xml;

import codeinn.CodeinnMIDlet;
import java.util.Hashtable;
import media.Video;
import util.Dictionary;

public class VideoHandler extends BaseHandler {

    private Dictionary videosList;
    private String tmpVideoTitle;
    private Video tmpVideo;

    public VideoHandler() {
        this.videosList = new Dictionary();
        this.tmpVideo = new Video();
        
    }

    public void processCharacters(String tree, String tagValue) {
        //System.out.println("\ntree -> "+tree+"\nvalue -> "+tagValue);
        if(tree.equals("videos|group|name") && tagValue != null) {
            this.videosList.put(tagValue, CodeinnMIDlet.MIDLET_RESPONSE_NULL);
        }
        if( tree.equals("videos|group|video|title") && tagValue != null)
            this.tmpVideoTitle = tagValue;
        if( tree.equals("videos|group|video|description") && tagValue != null)
            this.tmpVideo.setDescription(tagValue);
        if( tree.equals("videos|group|video|url") && tagValue != null) {
            this.tmpVideo.setUrl(tagValue);
            //System.out.println(this.tmpVideo);
            this.videosList.put(this.tmpVideoTitle, this.tmpVideo);
            this.tmpVideo = new Video();
        }
    }

    public void processStart(String tree, Hashtable hashTable) {
        //System.out.println("\n    tree ->\n"+tree+"\nhash ->\n"+hashTable.toString());
    }

    public Dictionary getVideosList() {
        return this.videosList;
    }
    
}
